export function appBack(){
    //子页返回触发
    document.addEventListener('plusready', function () {
        window.plus.key.addEventListener('backbutton', function () {
            var webview = window.plus.webview.currentWebview();
            webview.canBack(function (e) {
                if (e.canBack) {
                    webview.back();
                }
            })
        });
    });
  
  //在主页按返回按钮时触发
  document.addEventListener('plusready', function () {
    let time = null;
    window.plus.key.addEventListener('backbutton', function () {
        var webview = window.plus.webview.currentWebview();
        webview.canBack(function (e) {
            if (!e.canBack) {
                if (!time) {
                    time = new Date().getTime();
                    window.plus.nativeUI.toast('再按一次退出应用');
                    setTimeout(function () {
                        time = null;
                    }, 1000);
                } else {
                    if (new Date().getTime() - time < 1500) {
                        window.plus.runtime.quit();
                    }
                }
            }
        })
    });
  });
}
